package com.xxx.video.mine.activitys;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.xxx.video.R;
import com.xxx.video.commen.activitys.BaseActivity;
import com.xxx.video.commen.configs.UserManager;
import com.xxx.video.commen.utils.StatusBarUtil;
import com.xxx.video.login.activitys.LoginActivity;
import com.xxx.video.mine.presenters.ISettingView;

import butterknife.BindView;
import butterknife.OnClick;

public class SettingActivity extends BaseActivity implements ISettingView {
    @BindView(R.id.tv_setting_activity_account_information)
    TextView tvSettingActivityAccountInformation;
    @BindView(R.id.tv_setting_activity_app_setting)
    TextView tvSettingActivityAppSetting;
    @BindView(R.id.tv_setting_activity_about_us)
    TextView tvSettingActivityAboutUs;
    @BindView(R.id.tv_setting_activity_user_agreement)
    TextView tvSettingActivityUserAgreement;
    @BindView(R.id.tv_setting_activity_privacy_agreement)
    TextView tvSettingActivityPrivacyAgreement;
    @BindView(R.id.tv_setting_activity_privacy_permission_restrictions)
    TextView tvSettingActivityPrivacyPermissionRestrictions;
    @BindView(R.id.tv_setting_activity_logout)
    TextView tvSettingActivityLogout;

    @Override
    public void initToolbarData() {
        super.initToolbarData();
        showActionBar();
        StatusBarUtil.getInstance().setStatusBarTransparent(this, true);
        setIsShowActionbarLine(true);
        setActionBarTitle(R.string.title_setting_activity);
    }

    @Override
    public int getContentLayout() {
        return R.layout.activity_setting;
    }

    @Override
    public void initData(Bundle extras) {
        showRootLayoutStatus(1);
        initPreview();
    }

    @OnClick({R.id.tv_setting_activity_account_information, R.id.tv_setting_activity_app_setting, R.id.tv_setting_activity_about_us, R.id.tv_setting_activity_user_agreement, R.id.tv_setting_activity_privacy_agreement, R.id.tv_setting_activity_privacy_permission_restrictions, R.id.tv_setting_activity_logout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_setting_activity_account_information:
                startAccountInformationActivity();
                break;
            case R.id.tv_setting_activity_app_setting:
                startAppSettingActivity();
                break;
            case R.id.tv_setting_activity_about_us:
                startAboutMeActivity();
                break;
            case R.id.tv_setting_activity_user_agreement:
                break;
            case R.id.tv_setting_activity_privacy_agreement:
                break;
            case R.id.tv_setting_activity_privacy_permission_restrictions:
                break;
            case R.id.tv_setting_activity_logout:
                UserManager.getInstance().logOut();
                startLoginActivity();
                break;
            default:
                break;
        }
    }

    @Override
    public void showRootLayoutStatus(int status) {
        showLayoutStatus(status);
    }

    @Override
    public void startAccountInformationActivity() {
        intent2Activity(AccountInformationActivity.class);
    }

    @Override
    public void startAppSettingActivity() {
        intent2Activity(AppSettingActivity.class);
    }

    @Override
    public void startLoginActivity() {
        intent2Activity(LoginActivity.class);
        finish();
    }

    @Override
    public void startAboutMeActivity() {
        Bundle bundle = new Bundle();
        bundle.putString("Url", "file:android_asset/aboutme.html");
        intent2Activity(CommonWebViewActivity.class, bundle);
    }

    @Override
    public void initPreview() {
        if (UserManager.getInstance().isLogin()) {
            tvSettingActivityAccountInformation.setVisibility(View.VISIBLE);
            tvSettingActivityLogout.setVisibility(View.VISIBLE);
        } else {
            tvSettingActivityAccountInformation.setVisibility(View.GONE);
            tvSettingActivityLogout.setVisibility(View.GONE);
        }
    }
}
